package cn.wolfcode.wechat.service.impl;

import cn.wolfcode.wechat.domain.WelcomeMessage;
import cn.wolfcode.wechat.mapper.WelcomeMessageMapper;
import cn.wolfcode.wechat.service.IWelcomeMessageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class WelcomeMessageServiceImpl implements IWelcomeMessageService{

    @Resource
    private WelcomeMessageMapper welcomeMessageMapper;

    @Override
    public int insert(WelcomeMessage welcomeMessage){
        return welcomeMessageMapper.insert(welcomeMessage);
    }

    @Override
    public int update(WelcomeMessage welcomeMessage){
        return welcomeMessageMapper.update(welcomeMessage);
    }

    @Override
    public WelcomeMessage get(Long id) {
        return welcomeMessageMapper.getWelcomeMessage(id);
    }

    @Override
    public void saveOrUpdate(WelcomeMessage message) {
        if (message.getId()==null){
            this.insert(message);
        }else{
            this.update(message);
        }
    }
}
